import requests

from APis.baseAPI import BaseAPI
from common.config import ip


class LoginAPI(BaseAPI):

    # def login(self,uname='admin',upwd='123456'):
    #     loginData = {"username": uname, "password": upwd}
    #     self.r = requests.post(f"{ip}/login", data=loginData)
    #     print(self.r.json())
    #     return self.r

    def login(self, d={'username':'admin','password':'123456'}):
        self.r = requests.post(f"{ip}/login", data=d)
        print(self.r.json())
        return self.r
    def loginOK(self):
        t=self.r.json()['code']
        return t

    def loginError(self):
        t = self.r.json()['code']
        return t


if __name__ == '__main__':
    api = LoginAPI()
    print(api.login())
    print(api.loginOK())
    print(api.loginError())